package ch07_GUI编程;

import javax.swing.*;
import java.awt.*;

public class JPasswordFieldDemo {
	public static void main(String[] args) {
		BaseFrame f = new BaseFrame("JPasswordField Demo");
		String[] labStrs = { "默认密码框：", "指定回显字符（西文）：", "指定回显字符（中文）：", "密码可见：" };
		JLabel[] labs =new JLabel[labStrs.length];

		String[] pswStrs= {"admin","admin","admin","我是密码"};
		JPasswordField[] pfs =new JPasswordField[pswStrs.length];
		f.setLayout(new FlowLayout(FlowLayout.LEFT));
		for (int i = 0; i < pfs.length; i++) {
			labs[i]=new JLabel(labStrs[i]);
			pfs[i]=new JPasswordField(pswStrs[i]);
			f.add(labs[i]);
			f.add(pfs[i]);
		}
		pfs[1].setEchoChar('^');
		pfs[2].setEchoChar('*');
		pfs[3].setEchoChar('\u0000');

		f.showMe();
	}
}
